home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / checkbox / plugins / exchange_prompt.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-10-12  |  2.8 KB  |  66 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import posixpath
  5. import re
  6. from gettext import gettext as _
  7. from checkbox.lib.iterator import PREV
  8. from checkbox.properties import String
  9. from checkbox.plugin import Plugin
  10.  
  11. class ExchangePrompt(Plugin):
  12.     email = String(required = False)
  13.     
  14.     def register(self, manager):
  15.         super(ExchangePrompt, self).register(manager)
  16.         for rt, rh in [
  17.             ('gather-persist', self.gather_persist),
  18.             ('exchange-error', self.exchange_error),
  19.             ('exchange-report', self.exchange_report),
  20.             ('prompt-exchange', self.prompt_exchange)]:
  21.             self._manager.reactor.call_on(rt, rh)
  22.         
  23.  
  24.     
  25.     def gather_persist(self, persist):
  26.         self.persist = persist.root_at('exchange_prompt')
  27.  
  28.     
  29.     def exchange_error(self, error):
  30.         self._error = error
  31.  
  32.     
  33.     def exchange_report(self, report):
  34.         self._report = report
  35.  
  36.     
  37.     def prompt_exchange(self, interface):
  38.         if not self.persist.get('email'):
  39.             pass
  40.         email = self.email
  41.         self._error = None
  42.         while True:
  43.             if self._error or not (self.email):
  44.                 if self._error:
  45.                     interface.show_error(_('Exchange'), self._error)
  46.                 
  47.                 url = 'file://%s' % posixpath.abspath(self._report)
  48.                 email = interface.show_exchange(email, _('The following information will be sent to the Launchpad hardware database.\n\n[[%s|View Report]]\n\nPlease provide the e-mail address you use to sign in to Launchpad to submit this information.' % url))
  49.             
  50.             if interface.direction == PREV:
  51.                 break
  52.                 continue
  53.             if not re.match('^\\S+@\\S+\\.\\S+$', email, re.I):
  54.                 self._error = _('Email address must be in a proper format.')
  55.                 continue
  56.             self._error = None
  57.             self._manager.reactor.fire('report-email', email)
  58.             interface.show_wait(_('Exchanging information with the server...'), self._manager.reactor.fire, 'exchange')
  59.             if not self._error:
  60.                 break
  61.                 continue
  62.         self.persist.set('email', email)
  63.  
  64.  
  65. factory = ExchangePrompt
  66.